package ds.safelock.security;

/**
 * This class provides one-way encoding with sha-1 algorithm
 * @author David Silva
 * @version 1.0
 */
public class SHA {
	
	/**
	 * Encodes the given source data with sha-1 digest algorithm
	 * @param src data to be enconded
	 * @return byte array containing the src data encoded
	 */
	public static byte[] compute(byte[] src)
	{
		try
		{
			/* Instantiate the digest */
			final java.security.MessageDigest shaDigest = java.security.MessageDigest.getInstance(
												ds.safelock.config.Configuration.DIGEST_ALGORITHM_V2);
			shaDigest.reset();
			final byte[] hash = shaDigest.digest(src);
			return hash;
		}
		catch (java.security.NoSuchAlgorithmException e) { System.out.println(e.getMessage()); }
		return null;
	}

}
